package com.jobs.common.factory;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author xdh
 */
public class RabbitMqUtils {
    /**
     * 得到一个连接的 channel
     * @return
     * @throws Exception
     */
    public static Channel getChannel() throws Exception {
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("10.3.7.109");
        factory.setUsername("root");
        factory.setPassword("QweHxj@qjty");
        factory.setVirtualHost("/test_virtual_host");
        factory.setPort(5672);
        Connection connection = factory.newConnection();
        return connection.createChannel();
    }
}
